<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Basic usage</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="newt.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.newt.html">Newt 函数</a></div>
 <div class="up"><a href="newt.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="newt.examples-usage" class="section">
  <h2 class="title">Basic usage</h2>
  <p class="para">
   This example is a PHP port of RedHat &#039;setup&#039; utility dialog, executed in text
   mode.
  </p>
  <div class="example" id="example-608">
   <p><strong>Example #1 Newt Usage Example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />newt_init&nbsp;</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">newt_cls&nbsp;</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">newt_draw_root_text&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Test&nbsp;Mode&nbsp;Setup&nbsp;Utility&nbsp;1.12"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">newt_push_help_line&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">null</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">newt_draw_root_text&nbsp;</span><span style="color: #007700">(-</span><span style="color: #0000BB">30</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"(c)&nbsp;1999-2002&nbsp;RedHat,&nbsp;Inc"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">newt_get_screen_size&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">$rows</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$cols</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">newt_open_window&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">$rows</span><span style="color: #007700">/</span><span style="color: #0000BB">2</span><span style="color: #007700">-</span><span style="color: #0000BB">17</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$cols</span><span style="color: #007700">/</span><span style="color: #0000BB">2</span><span style="color: #007700">-</span><span style="color: #0000BB">10</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">34</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">17</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Choose&nbsp;a&nbsp;Tool"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$form&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">newt_form&nbsp;</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$list&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">newt_listbox&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">3</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">);<br /><br />foreach&nbsp;(array&nbsp;(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"Authentication&nbsp;configuration"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"Firewall&nbsp;configuration"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"Mouse&nbsp;configuration"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"Network&nbsp;configuration"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"Printer&nbsp;configuration"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"System&nbsp;services"</span><span style="color: #007700">)&nbsp;as&nbsp;</span><span style="color: #0000BB">$l_item</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">newt_listbox_add_entry&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">$list</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$l_item</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$l_item</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$b1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">newt_button&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">5</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">12</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Run&nbsp;Tool"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$b2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">newt_button&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">21</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">12</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Quit"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">newt_form_add_component&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">$form</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$list</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">newt_form_add_components&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">$form</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #0000BB">$b1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$b2</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">newt_refresh&nbsp;</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">newt_run_form&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">$form</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">newt_pop_window&nbsp;</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">newt_pop_help_line&nbsp;</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">newt_finished&nbsp;</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">newt_form_destroy&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">$form</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="newt.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.newt.html">Newt 函数</a></div>
 <div class="up"><a href="newt.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
